import React, { PureComponent } from 'react'
import { Button } from 'antd'
import { connect } from 'dva'
import { routerRedux } from 'react-router-dom'
import PropTypes from 'prop-types'
import PageHeaderLayout from '@/layouts/PageHeaderLayout'
import TemplateCard from '@/support/components/TemplateCard'
import CarMultiTrack from "./CarMultiTrack"

@connect(({ common, loading }) => ({
  common,
  loading: loading.models.common,
}))
export default class OverdueCarTrack extends PureComponent {
  static contextTypes = {
    dicData: PropTypes.object,
  }
  state = {
  }

  componentDidMount () {
  }

  onRef = (ref) => {
    this.trackRef = ref
  }

  goBack = () => {
    const { dispatch } = this.props
    this.trackRef.destroyMap()
    dispatch(routerRedux.push({ pathname: '/creditPlatform/overdueCar' }))
    // if (this.props.location && this.props.location.state) {
    //   const { pageObj, formValues } = this.props.location.state
    //   dispatch(routerRedux.push({ pathname: '/creditPlatform/overdueCar', state: { pageObj: pageObj, formValues } }))
    // } else {
    //   dispatch(routerRedux.push({ pathname: '/creditPlatform/overdueCar' }))
    // }
  }

  render () {
    return (
      <PageHeaderLayout>
        <TemplateCard>
          <Button style={{ marginLeft: '90%', marginBottom: '10px' }} type="primary" onClick={this.goBack}>返回</Button>
          <CarMultiTrack onRef={this.onRef} />
        </TemplateCard>
      </PageHeaderLayout>
    )
  }
}
